Ext.onReady(function() {
    Ext.create('Ext.form.Panel', {
        renderTo: 'login-container',
        width: 300,
        height: 200,
        title: 'Login',
        frame: true,
        bodyPadding: 10,
        defaultType: 'textfield',
        items: [{
            fieldLabel: 'Username',
            name: 'username',
            allowBlank: false
        }, {
            fieldLabel: 'Password',
            name: 'password',
            inputType: 'password',
            allowBlank: false
        }],
        buttons: [{
            text: 'Login',
            handler: function() {
                var form = this.up('form').getForm();
                if (form.isValid()) {
                   // console.log(form);
                 var  data = {};
                 var array = form.monitor.items.items;
                 for(var i in array){
                    item = array[i];
                    data[item.name] = item.value;
                 }
                 console.log(data);
                 //调jiekou
                 $.ajax({
                   url: 'http://localhost:9090/login',
                   type: 'POST',
                   data: JSON.stringify(data),
                   contentType : "application/json;charset=UTF-8",
                   dataType: "json",
                   success: function(response) {
                     // 请求成功时的回调函数
                     console.log('登录成功:', response);
                   },
                   error: function(xhr, status, error) {
                     // 请求失败时的回调函数
                     console.log('登录失败:', error);
                   }
                 });
                }
            }
        }]
    });
});